#include<cstdio>
#include<cstring>
using namespace std;

int n, a[22][22], dir = 0;
int dx[4] = {0, 1, 0,-1};
int dy[4] = {1, 0,-1, 0};
bool v[22][22];

int main() {
    int x = 1, y = 0, index = 1;
    memset(v, 0, sizeof(v));
    scanf("%d", &n);
    while(index <= n * n) {
        int xx = x + dx[dir];
        int yy = y + dy[dir];
        if(v[xx][yy] || xx<1 || yy<1 || xx>n || yy>n)
            dir = (dir+1) % 4;
        x += dx[dir];
        y += dy[dir];
        a[x][y] = index++;
        v[x][y] = true;
    }

    for(int i=1; i<=n; i++)  {
        for(int j=1; j<=n; j++)
            printf("%4d", a[i][j]);
        printf("\n");
    }
    return 0;
}